Skip to content

[6.x] Exclude private ($__) variables from cache context to resolve serialization exception - #15130

Merged
jasonvarga merged 4 commits into
statamic:6.xfrom
martyf:fix/nocache-region-ignore-private-variables
Aug 7, 2026
Merged

[6.x] Exclude private ($__) variables from cache context to resolve serialization exception #15130
jasonvarga merged 4 commits into
statamic:6.xfrom
martyf:fix/nocache-region-ignore-private-variables

Conversation

@martyf

@martyf martyf commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

When using @blaze in a Blade-based Statamic site, using the nocache tag or directive would result in an exception:

Serialization of 'Closure' is not allowed

Within the NoCache Region filterContext method, explicit context properties were removed, plus __env.

Blaze adds a __blaze which includes a closure - this is what is causing the exception to be thrown.

This PR keeps the same rejection, but instead of just __env, excludes any private variables (i.e. those prefixed with __).

If this feels too heavy-handed, another approach would be to revert to what it was, but add __blaze to the list too.

However, the challenge with this approach is that if future updates introduce new private variables with the same closure behaviour, the issue will re-occur.

So while the "exclude any private variable" is very wide, it also covers other internals being excluded (i.e. if things within Blaze, Blade, Livewire, etc, evolve).

@martyf

martyf commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Similar, but not identical to #6839

@jasonvarga
jasonvarga enabled auto-merge (squash) August 6, 2026 15:21
@jasonvarga
jasonvarga merged commit 370c189 into statamic:6.x Aug 7, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants